package recycle.controller;

import recycle.pojo.Customerlevelinf;
import recycle.service.CustomerlevelinfService;
import recycle.utils.Page;
import recycle.vo.CustomerlevelinfParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 描述：用户级别信息表 控制器
* @author 孙冉
* @date 2019/07/22
*/
@RestController
@RequestMapping("/customerlevelinf")
public class CustomerlevelinfController{
	@Resource
	private CustomerlevelinfService customerlevelinfService;
 	
 	@RequestMapping("/findById.json")
    public Customerlevelinf findById(Integer customerLevel){
        Customerlevelinf result = null;
        try {
            result = customerlevelinfService.findById(customerLevel);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：获取所有的Customerlevelinf对象
     */
    @RequestMapping("/findAll.json")
    public List<Customerlevelinf> findAll(){
        List<Customerlevelinf> result = null;
        try {
            result = customerlevelinfService.findAll();
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：新增保存Customerlevelinf对象
     */
    @RequestMapping("/save.json")
    public Map save(Customerlevelinf customerlevelinf){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存用户级别信息表失败");
        try {
            if(customerlevelinfService.save(customerlevelinf)>0){
                result.put("flag",true);
                result.put("msg","保存用户级别信息表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：根据主键删除用户级别信息表对象
     * @param customerLevel
     */
    @RequestMapping("/delete.json")
    public Map delete(Integer customerLevel){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","保存用户级别信息表失败");
        try {
            if(customerlevelinfService.delete(customerLevel)>0){
                result.put("flag",true);
                result.put("msg","保存用户级别信息表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 描述：更新用户级别信息表对象
     */
    @RequestMapping("/update.json")
    public Map update(Customerlevelinf customerlevelinf){
        Map result = new HashMap();
        result.put("flag",false);
        result.put("msg","更新用户级别信息表失败");
        try {
            if( customerlevelinfService.update(customerlevelinf)>0){
                result.put("flag",true);
                result.put("msg","更新用户级别信息表成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;

    }

    /**
     * 根据不确定的条件，动态查询
     */
    @RequestMapping("/query.json")
    public List<Customerlevelinf> query(CustomerlevelinfParam param){
        List<Customerlevelinf> result = null;
        try {
            result = customerlevelinfService.query(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }

    /**
     * 根据不确定的条件，动态分页查询
     */
    @RequestMapping("/queryByPage.json")
    public Page queryByPage(CustomerlevelinfParam param){
        Page result = null;
        try {
            result = customerlevelinfService.queryByPage(param);
        }catch (Exception e){
            e.printStackTrace();
        }
        return result;
    }
 }
